package Data;
import java.util.LinkedList;

import Data.*;
public class Automata {
	
	public LinkedList <Relation> relations;
	public LinkedList <State> states;
	public State initialState;
	
	
	public void setInitialState(State state){
		this.initialState=state;
	}
	public State getInitialState(){
		return this.initialState;
	}
	public LinkedList<Relation> getRelations() {
		return relations;
	}

	public void setRelations(LinkedList<Relation> relations) {
		this.relations = relations;
	}

	public LinkedList<State> getStates() {
		return states;
	}

	public void setStates(LinkedList<State> states) {
		this.states = states;
	}

	
	public Automata(){
		this.relations= new LinkedList <Relation>();
		this.states = new LinkedList <State>();
	}
	
	public State getStateByName (String stateName){
		for(int i=0; i<this.states.size(); i++){
			State temp = this.states.get(i);
			if(temp.getStateName().equalsIgnoreCase(stateName)){
				return temp;
			}
		}
		return null;
	}
	
	public boolean deleteStateByName (String stateName){
		for(int i=0; i<this.states.size(); i++){
			State temp = this.states.get(i);
			if(temp.getStateName().equalsIgnoreCase(stateName)){
				this.states.remove(i);
				System.out.println(this.states.size());
				return true;
				
			}
		}
		return false;
	}
}
